package network.course3.ScheduledThreadPool;



import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class Track {
    private static final String DATE_TIME = "yyyy-MM-dd HH:mm:ss";
    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME);
    private static final ScheduledExecutorService threadPool=Executors.newScheduledThreadPool(2);
    public static void main(String[] args) {
        System.out.println(LocalDateTime.now().format(formatter) + ": begin");
        // TODO 自动生成的方法存根
        Animal a1=new Animal("兔子", 5, 2000);
        Animal a2=new Animal("乌龟", 2, 2000);
        threadPool.scheduleAtFixedRate(a1, 1, 3, TimeUnit.SECONDS);
        threadPool.scheduleAtFixedRate(a2, 1, 1, TimeUnit.SECONDS);
    }
}
